home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / varia / rpc.lha / dynload / loaderPrivate.h < prev    next >
C/C++ Source or Header  |  1993-08-08  |  2KB  |  91 lines

  1. // Copyright (C) 1990 by Glenn Gribble; all rights are reserved.
  2. // This program may be used for any purposes including inclusion in
  3. // for profit programs.  If the source is copied, the copyright notice
  4. // must be included.  Please send bug fixes/reports to glenn@synaptics.com
  5. // This program is distributed without any warranty.
  6.  
  7. // -*- C++ -*-
  8. // %W% %G%
  9.  
  10. #ifndef LOADERPRIVATE_H
  11. #define LOADERPRIVATE_H
  12.  
  13. // For some reason, Sun did not put this in sys/mman.h
  14. extern "C" int mprotect(caddr_t addr, int len, int prot);
  15.  
  16. // This is what the __DYNAMIC structure is.  Found in <link.h>
  17. extern link_dynamic _DYNAMIC;
  18.  
  19. // Set the n_type field of an nlist to N_SET when the value is known good 
  20. #define N_SET N_TYPE
  21.  
  22. typedef unsigned char *memptr;
  23.  
  24. // An encapsulation of the symbol table in a file
  25. class symTable {
  26. friend symTable* loadSymTable(const char *fn, bool wholeFile);
  27.   nlist *realSymbols;
  28.   int    numRealSymbols;
  29.  
  30.   nlist **quickSymbols;
  31.   int    numQuickSymbols;
  32.  
  33. #ifdef sun3
  34.   void     showReloc(reloc_info_68k *rl, int size, memptr seg);
  35.   bool     doReloc(reloc_info_68k *rl, int size, memptr seg);
  36. #endif
  37.  
  38. #ifdef sun4
  39.   void     showReloc(reloc_info_sparc *rl, int size, memptr seg);
  40.   bool     doReloc(reloc_info_sparc *rl, int size, memptr seg);
  41. #endif
  42.  
  43.   void   fixup(char *strBase);
  44.   bool   mapit();
  45.   bool   copyin();
  46.   nlist *lookup(const char *name);    // Just find a symbol in table
  47.   nlist *value(nlist *v);        // fix nlist entry
  48.   symTable(const char *fn, bool wholeFile);
  49.   char  *FileName;
  50.   bool   good;
  51. public:
  52.   ~symTable();
  53.  
  54.   static symTable *top;
  55.   const char *fileName() { return FileName; }
  56.  
  57.   long data_offset;
  58.   long text_offset;
  59.  
  60.   symTable *prev;
  61.  
  62.   exec E;
  63.  
  64.   nlist *value(const char *name);    // Find and fix symbol in table
  65.   nlist *value(int indx);        // Fix symbol at indx in table
  66.   void printAll();
  67. };
  68.  
  69. class segment {
  70.   memptr _data;
  71.   int    _prot;
  72.   int    _len;
  73. public:
  74.   segment(memptr d, int l, int p) { _data =d; _len=l; _prot=p; }
  75.   segment(int l, int p=PROT_READ|PROT_WRITE|PROT_EXEC);
  76.  
  77.   memptr data() { return _data; }
  78.   int prot()    { return _prot; }
  79.   int len()     { return _len; }
  80.  
  81.   void setProt(int newprot);
  82.   void unmap();
  83. };
  84.  
  85. inline int debugSymbols()      { return d_symbols || d_all; }
  86. inline int debugRelocation()   { return d_relocation || d_all; }
  87. inline int debugExecs()        { return d_execs || d_all; }
  88. inline int debugConstructors() { return d_ctors || d_all; }
  89.  
  90. #endif  LOADERPRIVATE_H
  91.